package com.du.springmvc.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author : DuJiabao
 * @Project : spring-mvc
 * @Time : 2021/4/7 19:22
 * @Desc :
 */
//@ControllerAdvice
public class MyExceptionHandler {
  @ExceptionHandler(Exception.class)
  public ModelAndView allExceptionHandler(Exception e) {
    ModelAndView mv = new ModelAndView("error");
    mv.addObject("exception", e);
    System.out.println(mv);
    return mv;
  }
}
